#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define delBit(mask, k) ((mask) - getBit((mask), (k)) * pw[k])
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int INF = 1 << 30;
const ldb pi = fabsl(atan2(0.0, -1.0));
using namespace std;


const LL MOD = 1000000007;
class Matrix
{
	public:
		int n;
		LL **a;
		Matrix()
		{
			a = NULL;
			n = 0;
		}
		void init(int sz)
		{
			a = new LL*[sz];
			for (int i = 0; i < sz; i++)
			{
				a[i] = new LL[sz];
				for (int j = 0; j < sz; j++)
					a[i][j] = 0;
			}
			n = sz;
		}
		void free()
		{
			memset(a, 0, sizeof(LL) * n * n);
		}
		void destroy()
		{
			if (a)
				delete a;
			n = 0;
			a = NULL;
		}
		void identity(int n)
		{
			destroy();
			init(n);
			for (int i = 0; i < n; i++) a[i][i] = 1;
		}
		void operator = (const Matrix &b)
		{
			destroy();
			init(b.n);
			for (int i = 0; i < n; i++)
			{
				a[i] = new LL[n];
				for (int j = 0; j < n; j++)
				{
					a[i][j] = b.a[i][j];
				}
			}
		}
		LL getSum()
		{
			LL res = 0;
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					res += a[i][j];
					res %= MOD;
				}
			}
			return res;
		}
};

Matrix operator * (const Matrix &a, const Matrix &b)
{
	Matrix c;
	c.init(a.n);
	for (int i = 0; i < a.n; i++)
	{
		for (int j = 0; j < b.n; j++)
		{
			c.a[i][j] = 0;
			for (int k = 0; k < c.n; k++)
			{
				c.a[i][j] += (a.a[i][k] * b.a[k][j]) % MOD;
				c.a[i][j] %= MOD;
			}
		}
	}
	return c;
}

Matrix operator + (const Matrix &a, const Matrix &b)
{
	Matrix c;
	c.init(a.n);
	for (int i = 0; i < a.n; i++)
	{
		for (int j = 0; j < a.n; j++)             	
		{
			c.a[i][j] = (a.a[i][j] + b.a[i][j]) % MOD;
		}
	}
	return c;
}

Matrix operator - (const Matrix &a, const Matrix &b)
{
	Matrix c;
	c.init(a.n);
	for (int i = 0; i < a.n; i++)
	{
		for (int j = 0; j < a.n; j++)
		{
			c.a[i][j] = (a.a[i][j] - b.a[i][j]) % MOD;
		}
	}
	return c;
}

ostream &operator << (ostream &out, const Matrix &a)
{
	for (int i = 0; i < a.n; i++)
	{
		for (int j = 0; j < a.n; j++)
		{
			out << a.a[i][j] << " ";
		}
		out << "\n";
	}
	return out;
}

Matrix operator ^ (const Matrix &a, long long st)
{
	Matrix d, aa = a;
	d.identity(a.n);
	while (st)
	{
		if (st & 1)
			d = d * aa;
		st >>= 1;
		aa = aa * aa;
	}
	aa.destroy();
	return d;
}



int L, R;
int pw[10];
Matrix a;
Matrix ia;


void Load()
{
	cin >> L >> R;
}

Matrix d, t, ra, rs;

LL getPow(int N)
{
	d.identity(pw[3]);
	a = ia;
	cerr << (d * a).getSum() << "\n";
	while (N)
	{
		if (N & 1)
			d = d * a;
		N >>= 1;
		a = a * a;
	}
	cerr << d.getSum() << "\n";
	return d.getSum();
}

int sz;

void go(int n)
{                         
	if (n == 0)
	{
		ra.identity(pw[3]);
		rs.identity(pw[3]);
		return;
	}
	go(n / 2);
	t = rs;
	if (n % 2 == 0)
		t = t - ra;
	rs = rs + t * ra;
	ra = ra * ra;
	if (n % 2 == 1) ra = ra * ia;
}

LL sum(int n)
{
	if (n < 0) return 0;
	if (n == 0) return pw[3];
	go(n);
	sz = pw[3];
	return ra.getSum();
}

LL getSum(int l, int r)
{
	return sum(r) - sum(l - 1);
}

enum {BLK = 0, WHT, RED, YEL};

bool good(int l)
{
	if (getBit(l, 0) == getBit(l, 1) || getBit(l, 1) == getBit(l, 2))
		return false;
	if (getBit(l, 0) == WHT && getBit(l, 1) == YEL || getBit(l, 0) == YEL && getBit(l, 1) == WHT)
		return false;
	if (getBit(l, 1) == WHT && getBit(l, 2) == YEL || getBit(l, 1) == YEL && getBit(l, 2) == WHT)
		return false;
	if (getBit(l, 0) == RED && getBit(l, 1) == BLK || getBit(l, 0) == BLK && getBit(l, 1) == RED)
		return false;
	if (getBit(l, 1) == RED && getBit(l, 2) == BLK || getBit(l, 1) == BLK && getBit(l, 2) == RED)
		return false;
	if (getBit(l, 0) == BLK && getBit(l, 1) == WHT && getBit(l, 2) == RED
	|| getBit(l, 2) == BLK && getBit(l, 1) == WHT && getBit(l, 0) == RED)
		return false;
	return true;
}

string format(int mask)
{
	string s;
	for (int i = 0; i < 3; i++)
	{
		if (getBit(mask, i) == BLK)
			s += "B";
		else if (getBit(mask, i) == WHT)
			s += "W";
		else if (getBit(mask, i) == YEL)
			s += "Y";
		else if (getBit(mask, i) == RED)
			s += "R";
	}
	reverse(s.begin(), s.end());
	return s;
}

LL pal2()
{
	LL res = 0;
	for (int i = 0; i < pw[2]; i++)
	{
		if (good(i)) res++;
	}
	return res;
}

LL count(int L, int R)
{
	if (L > R) return 0;
	LL res = getSum(L, R);
	if (L == 1) 
	{
		res -= pal2();
		L++;
	}
	if (L > R) return res;
	if (L == 2)
	{
		res -= pal2();
		L++;
	}
	if (L > R) return res;
	res += getSum(L, R);
}
                                                
void Solve()
{
	int i;
	int j;
	pw[0] = 1;
	pw[1] = 4;
	for (i = 2; i <= 5; i++)
		pw[i] = pw[i - 1] * pw[1];
	ia.init(pw[3]);
	for (i = 0; i < pw[3]; i++)
	{
		for (j = 0; j < pw[3]; j++)
		{
			if (good(i) && good(j) && delBit(i, 2) == j / pw[1])
			{
				cerr << format(i) << " " << format(j) << "\n";
				ia.a[i][j] = 1;
			}
		}
	}
	LL res = count(max(L - 2, 1), R - 2);
	L -= 2;
	R -= 2;
	
	
	LL res = getSum(L, R);
	if (L % 2 == 0)
	{
		res -= getPow((L + 1) / 2);
		res %= MOD;
		L++;
	}
	if (R % 2 == 1)
	{
		res -= getPow((R + 1) / 2);
		res %= MOD;
		R--;
	}
	res -= 2 * getSum((L + 1) / 2, (R + 1) / 2);
	res %= MOD;
	res += MOD;
	res %= MOD;
	cout << res;
}

#define file "d"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}
